<template>
  <div>我是孙子组件
    金额: <input v-model.number="form.refundPrice" @input="priceInput" />
    <button @click="handleClick">触发祖先组件方法</button>
    {{ userInfo }}
    用户朋友圈{{ userList }}
  </div>
</template>

<script>
import { mapState, mapMutations, mapActions } from "vuex"
export default {
  components: {},
  props: {},
  inject: ['page', 'msg', 'showInput'],
  data () {
    return {
      form: {
        refundPrice: 0
      }
    }
  },
  computed: {
    ...mapState({
      userInfo: state => state.userinfo.userInfo,
      userList: state => state.userinfo.userList
    }),
    // userInfo () {
    //   // return this.$store.state.userinfo.userInfo
    //   console.log("this.$store.getters", this.$store)
    //   return this.$store.getters['userinfo/userInfoResult']
    // }
  },
  methods: {
    // ...mapActions('userinfo', ['saveUserInfo']),
    handleClick () {
      // this.showInput();
      this.$store.dispatch("userinfo/saveUserInfo", { name: "suming", age: 35, address: "山东省潍坊市" })
      this.$store.dispatch("userinfo/saveUserList", [{ name: "张三", age: 18 },
      { name: "李四", age: 20 },
      { name: "王五", age: 22 }])
      // this.saveUserInfo({ name: "suming", age: 35, address: "山东省潍坊市" })
    },
    priceInput () {
      this.form.refundPrice = 100
    }
  },
  created () {
    console.log("我是孙子组件的created", this)
    console.log("我是孙子组件的created", this.page, this.msg)
  },
  mounted () {

  },
}
</script>
<style scoped></style>